<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改资产')" />
    <th:block th:include="include :: select2-css" />
</head>
<body>
<div class="main-content">
    <form class="form-horizontal" id="form-asset-edit" th:object="${fundAsset}">
        <h4 class="form-header h4">基本信息</h4>
        <h1 class="form-header h1">注意：此处修改为强制修改，不涉及到现金变动。 如果是购入新的资产，先把[资产数量]写为0，再进行资产交易。</h1>

        <div class="row">
            <input name="userId"  type="hidden"  th:field="*{id}" />
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">基金名称：</label>
                    <div class="col-sm-8">
                        <input name="assetName" placeholder="请输入基金名称" class="form-control" type="text" th:field="*{assetName}" readonly>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">基金类型：</label>
                    <div class="col-sm-8">
                        <input name="typeName"  class="form-control" type="text" th:field="*{typeName}" readonly>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">基金数量：</label>
                    <div class="col-sm-8">
                        <input id="numberOf" name="numberOf" placeholder="请输入基金数量" class="form-control" type="number" th:field="*{numberOf}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">成本总价：</label>
                    <div class="col-sm-8">
                        <input id="costOf" name="costOf" placeholder="请输入成本总价" class="form-control" type="number" th:field="*{costOf}"  required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">成本单价：</label>
                    <div class="col-sm-8">
                        <input id="costPrice" name="costPrice" placeholder="请输入成本单价，这个是根据成本总价和数量算的" class="form-control" type="number" th:field="*{costPrice}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">历史收入：</label>
                    <div class="col-sm-8">
                        <input id="historyEarnings" name="historyEarnings" placeholder="历史收入没有就填0" class="form-control" type="number" th:field="*{historyEarnings}" required>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
    var prefix = ctx + "finance/asset";

    $("#form-asset-edit").validate({
        onkeyup: false,
        rules:{
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-asset-edit").serializeArray();
            var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
            var roleIds = $.form.selectCheckeds("role");
            var postIds = $.form.selectSelects("post");
            data.push({"name": "status", "value": status});
            data.push({"name": "roleIds", "value": roleIds});
            data.push({"name": "postIds", "value": postIds});
            $.operate.saveTab(prefix + "/edit", data);
        }
    }

    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    $(function() {
        $('#post').select2({
            placeholder: "请选择岗位",
            allowClear: true
        });
    })
</script>
</body>
</html>